import { ReqPage, ResPage } from '@/api/interface'
import { TBY } from '@/api/config/servicePort'
import http from '@/api'

export namespace UavRecord {
  /**查询参数 */
  export interface Query extends ReqPage {
    taskCode?: string
    useDate?: any
    useDateBegin?: string
    useDateEnd?: string
  }

  /**列表内容 */
  export interface Record {
    id: number
    uavId: number
    navName: string
    flightDistance: number
    flightTime: number
    useDate: string
    useDateFormat: string
    taskCode: string
  }

  /**详情 */
  export interface Form {
    id: number
    uavId: number
    flightDistance: number
    flightTime: number
    taskCode: string
    useDate: string
    useDateFormat: string
  }

  export const TaskCodeEnum = [
    { value: '0', label: '日常巡护' },
    { value: '1', label: '防火巡查' },
    { value: '2', label: '违法图斑识别' },
    { value: '3', label: '松材线虫监测' },
    { value: '4', label: '古树名木监测' }
  ]
}

// 分页查询
export const pageUavRecord = (params: UavRecord.Query) => {
  return http.get<ResPage<UavRecord.Record>>(TBY + `/uav_record/page`, params)
}

// 列表查询
export const listUavRecord = (params: UavRecord.Query) => {
  return http.get<UavRecord.Record[]>(TBY + `/uav_record/list`, params)
}

// 详情信息
export const getUavRecordDetail = (id: number) => {
  return http.get<Partial<UavRecord.Form>>(TBY + `/uav_record/get`, { id }, { loading: false })
}

// 新增或修改
export const saveOrUpdateUavRecord = (params: Partial<UavRecord.Form>) => {
  return http.post(TBY + `/uav_record/save`, params)
}

// 删除
export const removeUavRecord = (id: number) => {
  return http.delete(TBY + `/uav_record/delete`, { id })
}
